﻿namespace WareHouse.Contract.Services
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    using WareHouse.Contract.Models;
    using WareHouse.Data;

    public interface IWareHouseService
    {
        #region Agency
        List<AgencyModel> ListAgency();

        AgencyModel SaveOrUpdateAgency(AgencyModel model);

        bool DeleteAgency(AgencyModel model);
        AgencyModel GetCurrentAgency();


        #endregion

        #region Company
        List<CompanyModel> ListCompany();

        CompanyModel SaveOrUpdateCompany(CompanyModel model);

        bool DeleteCompany(CompanyModel model);



        #endregion

        #region Unit
        List<UnitModel> ListUnit();

        UnitModel SaveOrUpdateUnit(UnitModel model);

        bool DeleteUnit(UnitModel model);


        #endregion

        #region Item Type
        List<ItemTypeModel> ListItemType();

        ItemTypeModel SaveOrUpdateItemType(ItemTypeModel model);

        bool DeleteItemType(ItemTypeModel model);


        #endregion

        #region Item Type
        List<GroupUserModel> ListGroupUser();

        GroupUserModel SaveOrUpdateGroupUser(GroupUserModel model);

        bool DeleteGroupUser(GroupUserModel model);
        List<GroupUserModel> ListGroupUserWithoutAdministratorGroup();

        #endregion


        #region Item
        List<ItemModel> ListItem();

        ItemModel SaveOrUpdateItem(ItemModel model);

        bool DeleteItem(ItemModel model);

        List<ItemModel> ListItemByWareHouseId(int wareHouseId);

        #endregion

        #region Item Price
        List<ItemPriceModel> ListItemPriceByItemId(int itemId);

        ItemPriceModel SaveOrUpdateItemPrice(ItemPriceModel model);

        bool DeleteItemPrice(ItemPriceModel model);

        bool IsCheckOverLapItemPrice(int itemPriceId, DateTime effectiveFrom, DateTime? effectiveTo, int itemId);

        bool IsHaveCurrentPrice(int itemId);

        ItemPriceModel GetPriceInPast(DateTime dateCreateExport, int itemId);
        #endregion



        #region  Customer

        List<CustomerModel> ListCustomer();

        CustomerModel SaveOrUpdateCustomer(CustomerModel model);

        bool DeleteCustomer(CustomerModel model);
        CustomerModel GetCustomerByCustomerId(int customerId);

        #endregion


        #region WareHouse

        List<WareHouseModel> LoadWareHouseSales();

        List<WareHouseModel> ListWareHouse();

            #endregion

        #region Export & Export Detail

        string GetExport();

        bool SaveExport(ExportModel model);

        bool SaveExportDetail(List<ExportDetailModel> listModel, ExportModel exportModel);

        List<ExportModel> ListAllExport();
        List<ExportDetailModel> ListItemByExportId(string exportId);
        List<CustomerDebtModel> ListItemByCustomerId(int customerId);

        List<CustomerDebtModel> ListItemByCustomerId(
            int customerId,
            DateTime effectiveFromDate,
            DateTime effectiveTodate);
        bool UpdateQuantityInExported(EditExpAndImpModel editExpAndImpModel);
        bool CheckQuantityInWareHouse(EditExpAndImpModel editExpAndImpModel);
        #endregion
        #region Department
        List<DepartmentModel> ListDepartment();

        DepartmentModel SaveOrUpdateDepartment(DepartmentModel model);

        bool DeleteDepartment(DepartmentModel model);


        #endregion

        #region  Employer

        List<EmployerModel> ListEmployer();

        EmployerModel SaveOrUpdateEmployer(EmployerModel model);

        bool DeleteEmployer(EmployerModel model);


        #endregion

        #region  CustomerDebtRate

        List<CustomerDebtRateModel> ListCustomerDebtRate();

        CustomerDebtRateModel SaveOrUpdateCustomerDebtRate(CustomerDebtRateModel model);

        bool DeleteCustomerDebtRate(CustomerDebtRateModel model);


        #endregion

        #region Import & Import Detail

        string GetImport();

        bool SaveImport(ImportModel model);

        bool SaveImportDetail(List<ImportDetailModel> listModel, ImportModel ImportModel);

        List<ImportModel> ListAllImport();
        List<ImportDetailModel> ListItemByImportId(string ImportId);

        bool UpdateQuantityInImported(EditExpAndImpModel editExpAndImpModel);

        List<ItemModel> ListItemByWareHouseIdForImport();

        #endregion

        #region WareHouse Type
        List<WareHouseTypeModel> ListWareHouseType();

        WareHouseTypeModel SaveOrUpdateWareHouseType(WareHouseTypeModel model);

        bool DeleteWareHouseType(WareHouseTypeModel model);


        #endregion

        #region Item Type
       

        WareHouseModel SaveOrUpdateWareHouse(WareHouseModel model);

        bool DeleteWareHouse(WareHouseModel model);


        #endregion

        bool SavesDetailCustomerPaidHistory(List<DetailCustomerPaidHistoryModel> listModel);

        bool SetExportIsPaidTrueToFalse(List<ExportModel> listExportModel);

        CustomerPaidHistoryModel SaveOrUpdateCustomerPaidHistory(CustomerPaidHistoryModel model);

        bool EndDebtForCustomer(List<DetailCustomerPaidHistoryModel> listDetailCustomerPaidHistory, CustomerPaidHistoryModel customerPaidHistoryModel, List<ExportModel> listExportModel);

        decimal GetTotalDebt(int customerId);

        decimal GetTotalCustomerPaidButNotEnd(int customerId);

        List<CustomerPaidHistoryModel> GetCustomerPaidHistoryByCustomerId(int customerId);

        List<DetailCustomerPaidHistoryModel> GetDetailCustomerPaidHistoryByCustomerPaidHistoryId(int customerPaidHistoryId);

        CustomerPaidHistoryModel AddMoreMoney(CustomerPaidHistoryModel model);

            #region Security
        /// <summary>
        /// The login with user name and password.
        /// parameter 0 : login succeed or not
        /// parameter 1  : isAdmin or not
        /// parameter 2 : username
        /// parameter 3 : group User ID
        /// </summary>
        
        UserAccountModel LoginWithUserNameAndPassword(string userName, string password);

        #endregion



        #region Report

        List<ReportTotalEndDayModel> ReportExistByDay(int warehouseId, DateTime dateView);
        List<ReportTotalEndDayDetailModel> ReportExistDetailByDay(int warehouseId, DateTime dateView);

        #endregion

        #region Order & Order Detail

        string GetOrder();

        bool SaveOrder(OrderModel model);

        bool SaveOrderDetail(List<OrderDetailModel> listModel, OrderModel OrderModel);


        List<OrderModel> ListAllOrder();
        List<OrderDetailModel> ListItemByOrderId(string OrderId);

        bool UpdateStatusFinishOrnotForOrder(OrderModel model);

        CompanyModel GetcompanyBycompanyId(int companyId);

        #endregion


        #region  UserAccount

        List<UserAccountModel> ListUserAccountWithoutAdministrator();

        UserAccountModel SaveOrUpdateUserAccount(UserAccountModel model, bool isNewAccount);

        bool DeleteUserAccount(UserAccountModel model);

        string ResetPasswordByUserName(string username);

        bool ChangePassword(string username, string oldPass, string newPass);



        #endregion


        #region Permit
        bool DeleteAllRoleByGroupUserId(int groupUserId);

        List<DetailGroupUserRoleModel> GetDetailRoleByGroupUserId(int groupUserId);

        bool SaveListRoleForGroupUser(List<DetailGroupUserRoleModel> listModel);
        bool R(int groupUserId, string roldId);

        #endregion
    }
}
